package com.jsoft.android.as;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class LP1 extends ListActivity {

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        //setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CHARACTERS));
        //String[] weapons = getResources().getStringArray(R.array.lightning_tier1_array);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, LP.elements
        		));

        ListView lv = getListView();

    	Toast.makeText(getApplicationContext(), "picking a weapon", Toast.LENGTH_SHORT).show();

        lv.setOnItemClickListener(new OnItemClickListener() {

		public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {
            // When clicked send the TextView text
           
            Bundle bundle = new Bundle();
            bundle.putCharSequence("what", ((TextView) view).getText());
            
            Intent mIntent = new Intent();
            mIntent.putExtras(bundle);
            setResult(RESULT_OK, mIntent);
            //setResult(RESULT_OK);
            finish();
            
          }
        });
    }
}
